const path = require('path');

const webpackConfig = {
    entry: {
        app: './src/app.js'
    },
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: '[name].min.js',
        publicPath: './dist/'
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    //{loader: "style-loader/url"}, //用url的时候不需要css-loader但是需要file-loder
                    //{loader: "style-loader/useable"}, //用useable的时候不需要file-loader但是需要css-loder
                    {
                        loader: "style-loader",
                        options: {
                            singleton: true,
                            insertAt: 'top',
                            // insertInto: '#box',
                            attrs: {id: 'style-id', class: 'style-class'},
                            transform: path.resolve(__dirname, './src/styles/transform.js')
                        }
                    },
                    {
                        loader: "css-loader",
                        options: {
                            minimize: true,
                            modules: true,
                            localIdentName: '[local]-[hash:base64:5]'
                        }
                    }
                ]
            }
        ]
    }
};

module.exports = webpackConfig;